package com.javaxxf.service;

import com.javaxxf.mappers.UserMapper;
import com.javaxxf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xuxiaofei
 * @date 2021年09月13日下午4:49
 * @联系作者：如果你有什么不懂，可以加作者微信 xxf960513 一起交流学习
 */

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
   //查询全部用户
    public List<User> findAll() {
        List<User> all = userMapper.findAll();
        return all;
    }
    //根据id查询用户
    public User findUserById(Integer id) {
        return userMapper.findUserById(id);
    }
    //添加用户
    public int save(User user) {
        return userMapper.save(user);

    }
    //更新用户
    public int update(User user) {
        return userMapper.update(user);

    }
    //根据ID删除用户
    public int delete(Integer id){
        return userMapper.delete(id);
    }

}
